package io.renren.modules.dangan.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import io.renren.common.validator.ValidatorUtils;
import io.renren.modules.sys.controller.AbstractController;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import io.renren.modules.dangan.entity.DaUserFlhEntity;
import io.renren.modules.dangan.service.DaUserFlhService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * ${comments}
 *
 * @author Mark
 * @email sunlightcs@gmail.com
 * @date 2019-09-02 22:01:22
 */
@RestController
@RequestMapping("danganSys/dauserflh")
@CrossOrigin
public class DaUserFlhController extends AbstractController {
    @Autowired
    private DaUserFlhService daUserFlhService;

    /**
     * 列表
     */
    @RequestMapping("/list")
//    @RequiresPermissions("dangan:dauserflh:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = daUserFlhService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{recid}")
    @RequiresPermissions("dangan:dauserflh:info")
    public R info(@PathVariable("recid") String recid){
        DaUserFlhEntity daUserFlh = daUserFlhService.getById(recid);

        return R.ok().put("daUserFlh", daUserFlh);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("dangan:dauserflh:save")
    public R save(@RequestBody DaUserFlhEntity daUserFlh){
        daUserFlhService.save(daUserFlh);

        return R.ok();
    }
    /**
     * 批量保存
     */
    @RequestMapping("/saveBatch")
//    @RequiresPermissions("dangan:dauserflh:save")
    public R saveBatch(@RequestParam("daUserFlh") List<String> daUserFlh, int userId){
        boolean res=daUserFlhService.saveBatch(userId,daUserFlh);
        if(res){
            return R.ok();
        }else{
            return R.error("保存失败");
        }
    }
    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("dangan:dauserflh:update")
    public R update(@RequestBody DaUserFlhEntity daUserFlh){
        ValidatorUtils.validateEntity(daUserFlh);
        daUserFlhService.updateById(daUserFlh);
        
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("dangan:dauserflh:delete")
    public R delete(@RequestBody String[] recids){
        daUserFlhService.removeByIds(Arrays.asList(recids));

        return R.ok();
    }

}
